from flask import Blueprint
from flask_restful import Api

from utils.constants import BASE_URL_PRIFIX

from .channel import UserChannelResource
from .passport import SMSCodeResource, LoginResource

# flask 蓝图对象
from .profile import CurrentUserResource

user_bp = Blueprint('user',__name__,url_prefix=BASE_URL_PRIFIX)

# API 对象
user_api = Api(user_bp)


# 设置json包装格式
from utils.output import output_json
user_api.representation('application/json')(output_json)

# 注册路由 添加类视图
user_api.add_resource(SMSCodeResource,'/sms/codes/<mob:mobile>')
user_api.add_resource(LoginResource,'/authorizations')
user_api.add_resource(CurrentUserResource, '/user')
user_api.add_resource(UserChannelResource, '/user/channels')
